package com.neusoft.neuiotms.dcam.fixed.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.dcam.fixed.model.enums.ExtFieldDataTypeEnum;

import lombok.Getter;
import lombok.Setter;

/**
 * @author wys
 */
@Getter
@Setter
@Entity
@Table(name = "neuiot_asset_ext_field_config")
@org.hibernate.annotations.Table(appliesTo = "neuiot_asset_ext_field_config", comment = "固定资产扩展属性配置表")
public class AssetExtFieldConfig extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @Column(nullable = false, unique = true)
    @Comment("bit(1) NOT NULL COMMENT '序号'")
    private Long sequence;

    @NotBlank(message = "字段名不能为空")
    @Length(max = 30, message = "资产名不能超过{max}位")
    @Column(length = 30, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '字段名'")
    private String name;

    @Length(max = 10, message = "扩展列字段")
    @Column(length = 10, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '扩展列字段'")
    private String extColumn;

    @Comment("bit(1) COMMENT '是否必填'")
    private Boolean required = false;

    @Comment("bit(1) COMMENT '是否显示'")
    private Boolean showed = false;

    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '默认值'")
    private String defaultValue;

    @Enumerated(EnumType.STRING)
    @NotNull(message = "数据类型不能为空")
    @Comment("varchar(255) NOT NULL COMMENT '数据类型'")
    private ExtFieldDataTypeEnum dataType = ExtFieldDataTypeEnum.text;

    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '数据值域'")
    private String dataValue;

    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '校验规则'")
    private String validateRule;

    @NotNull(message = "状态不能为空")
    @Comment("bit(1) COMMENT '状态是否启用'")
    private Boolean status = false;

}
